﻿<Window x:Class="Yorrick.FlickrMetadataSynchr.Log.LogWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:common="clr-namespace:Yorrick.Common"
	Icon="..\Resources\app.ico"
	common:WindowSettings.Save="True"
	MinHeight="200" MinWidth="200"
    Name="TheLogWindow"
    Title="Flickr Metadata Synchr Activity Log" Height="600" Width="500" Left="600">
	<Window.Resources>
        <common:DateTimeFormatter x:Key="formatter" />

        <DataTemplate x:Key="ActivityItemsTemplate">
			<StackPanel>
				<WrapPanel>
					<TextBlock Text="{Binding Path=OccurredAt, Converter={StaticResource formatter}, ConverterParameter=yyyy-MM-dd HH:mm:ss, Mode=OneWay}"
                           Width="Auto" Foreground="#FFA0A0A0" />
					<TextBlock Text="{Binding Path=MessageType, Mode=OneWay}" Margin="10,0,0,0" Foreground="#FFA0A0A0" />
				</WrapPanel>
				<TextBlock Text="{Binding Path=Message, Mode=OneWay}" Margin="16,0,0,0" />
			</StackPanel>
		</DataTemplate>
		<Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
			<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
			<Setter Property="Padding" Value="2,0,0,0"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ListBoxItem}">
						<Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
							<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsSelected" Value="true">
								<Setter Property="Background" Value="Blue"/>
								<Setter Property="Foreground" Value="White"/>
							</Trigger>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="true"/>
									<Condition Property="Selector.IsSelectionActive" Value="false"/>
								</MultiTrigger.Conditions>
								<Setter Property="Background" Value="LightBlue"/>
								<Setter Property="Foreground" Value="White"/>
							</MultiTrigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</Window.Resources>
    <ListBox Height="Auto" Name="ActivityList" Width="Auto" 
    	ItemsSource="{Binding Path=ActivityItems, ElementName=TheLogWindow, Mode=OneWay}" ItemTemplate="{DynamicResource ActivityItemsTemplate}" ItemContainerStyle="{DynamicResource ListBoxItemStyle}" />
</Window>
